<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * AdminInterface View
 */
class WelliVermittlungViewAdminInterfaces extends JViewLegacy
{
        /**
         * HelloWorlds view display method
         * @return void
         */
        function display($tpl = null) 
        {
                // Get data from the model
                $items = $this->get('Items');
                $pagination = $this->get('Pagination');
 
                // Check for errors.
                if (count($errors = $this->get('Errors'))) 
                {
                        JError::raiseError(500, implode('<br />', $errors));
                        return false;
                }
                // Assign data to the view
                $this->items = $items;
                $this->pagination = $pagination;
 
                // Set the toolbar
                $this->addToolBar($this->pagination->total);
                //$this->addToolBar();
                $this->getToolbar();
 
                // Display the template
                parent::display($tpl);
				
                // Set the document
                $this->setDocument();
        }
 
        /**
         * Setting the toolbar
         */
        protected function addToolBar($total=null) 
        {
            $path = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'toolbar.php';
            $fIsFile = is_file($path);
            
            JLoader::register('JToolBarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
            
                JToolBarHelper::title(JText::_('COM_WELLIVERMITTLUNG_MANAGER_ADMININTERFACE').
                        //Reflect number of items in title!
                        ($total?' <span style="font-size: 0.5em; vertical-align: middle;">('.$total.')</span>':'')
                        , 'admininterface');
                JToolBarHelper::deleteList('', 'admininterfaces.delete');
                JToolBarHelper::editList('admininterface.edit');
                JToolBarHelper::addNew('admininterface.add');
        }
		
	function getToolbar() 
        {
		// add required stylesheets from admin template
                $document = JFactory::getDocument();
                $document->addStyleSheet('administrator/templates/isis/css/template.css');
                //now we add the necessary stylesheets from the administrator template
                //in this case i make reference to the isis default administrator template in joomla 3.2
                $document->addCustomTag( '<link href="administrator/templates/isis/css/template.css" rel="stylesheet" type="text/css" />'."\n\n" );
                //load the JToolBar library and create a toolbar
                jimport('cms.html.toolbar');
		$bar = new JToolBar( 'toolbar' );
		//and make whatever calls you require
		$bar->appendButton( 'Standard', 'save', 'Save', 'yourcom.save', false );
		$bar->appendButton( 'Separator' );
		$bar->appendButton( 'Standard', 'cancel', 'Cancel', 'yourcom.cancel', false );
		//generate the html and return
		return $bar->render();
	}
        
        /**
         * Method to set up the document properties
         *
         * @return void
         */
        protected function setDocument() 
        {
                $document = JFactory::getDocument();
                $document->setTitle(JText::_('COM_WELLIVERMITTLUNG_ADMINISTRATION'));
        }
}
